package com.yuanfeng.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanfeng.business.entity.ShopMemberGradeEntity;
import com.yuanfeng.business.mapper.ShopMemberGradeMapper;
import com.yuanfeng.business.service.ShopMemberGradeService;
import com.yuanfeng.commoms.util.ParseMapUtils;
import com.yuanfeng.commoms.vo.shop.ShopMemberVO;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 *
 */
@Service
public class ShopMemberGradeServiceImpl extends ServiceImpl<ShopMemberGradeMapper, ShopMemberGradeEntity>
    implements ShopMemberGradeService{

    @Override
    public ShopMemberVO getGradeByIds(String userId, String shopId) {
        ShopMemberVO member = new ShopMemberVO();
        member = this.baseMapper.getGradeByIds(userId, shopId);
        if (member == null) {
            ShopMemberGradeEntity entity = this.baseMapper.selectById(1);
            try {
                Map map = ParseMapUtils.beanToMap(entity);
                member = ParseMapUtils.parseMap2Object(map, ShopMemberVO.class);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return member;
    }
}




